using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Portal.BO.Editoral.Statistic;

namespace Portal.GUI.EditoralOffice.MainOffce.Statistic
{
    public partial class StatContentDetail : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string news_id = Request.QueryString["NewsRef"] != null ? Request.QueryString["NewsRef"].ToString() : "-1";
                if (news_id == "")
                    news_id = "-1";

                string strData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
                strData += "<chart>\n";
                strData += "<series>\n";
                strData += "{0}";
                strData += "</series>\n";
                strData += "<graphs>\n";
                strData += "    <graph gid=\"1\">\n";
                strData += "    {1}";
                strData += "    </graph>\n";
                strData += "</graphs>\n";
               

                strData += "<labels>\n";
                strData += "    <label lid=\"0\">\n";
                strData += "         <x>20</x>\n";
                strData += "         <y>20</y>\n";
                strData += "         <rotate></rotate>\n";
                strData += "         <width></width>\n";
                strData += "         <align>center</align>\n";
                strData += "         <text_color></text_color>\n";
                strData += "         <text_size></text_size>\n";
                strData += "         <text><![CDATA[<b>{2}</b>]]></text> \n";
                strData += "    </label>\n";
                strData += "</labels>\n";

                strData += "</chart>\n";
                        
    
                     
                      
               
                
              
       
          
                          
        
     

                string strSeries = "";
                string strGraph = "";


                DataTable dt = StatContentHelper.GetListStatisticContentHour(news_id);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    strSeries += "<value xid=\"" + i + "\">" + dt.Rows[i]["Hour"] + "h" + " " + Convert.ToDateTime(dt.Rows[i]["Date"]).ToString("dd/MM") + "</value>\n";
                    strGraph += "<value xid=\"" + i + "\">" + dt.Rows[i]["PageView"]  + "</value>\n";
                }

                if (dt.Rows.Count > 0)
                {
                    for (int i = dt.Rows.Count; i < 24; i++)
                    {
                        strSeries += "<value xid=\"" + i + "\"></value>\n";
                        strGraph += "<value xid=\"" + i + "\"></value>\n";
                    }
                }

                string strNewsTitle = HttpUtility.HtmlDecode(Request.QueryString["NewsTitle"].ToString());

                strData = string.Format(strData, strSeries, strGraph, strNewsTitle);

                Response.Write(strData);

            }
        }
    }
}